#ifndef __memory_h__
#define __memory_h__


/* The SPI serial memory parameters */
#if defined BSP_TWRMCF51CN  || defined BSP_TWRMCF51MM  || defined BSP_MCF51AC    || \
    defined BSP_TWRMCF51JE  || defined BSP_MCF51JMEVB  || defined BSP_TWRMCF51AG || \
    defined BSP_MCF51JMDEMO || \
    defined BSP_TWRMCF52259 || defined BSP_M52277EVB   || defined BSP_M5208EVB   || \
    defined BSP_M53015EVB   || defined BSP_M5329EVB   ||\
    defined BSP_TWRMCF54418 || \
    defined BSP_TWRMPC5125  || BSP_TWR_K60N512
    /* number of bytes used for addressing within memory */
    #define SPI_MEMORY_ADDRESS_BYTES 3        
#else
    /* number of bytes used for addressing within memory */
    #define SPI_MEMORY_ADDRESS_BYTES 2
#endif

/* page size - maximum bytes per write */
#define SPI_MEMORY_PAGE_SIZE     0x0100   

/* The SPI serial memory instructions */

#define SPI_MEMORY_WRITE_STATUS           0x01
#define SPI_MEMORY_WRITE_DATA             0x02
#define SPI_MEMORY_READ_DATA              0x03
#define SPI_MEMORY_WRITE_LATCH_DISABLE    0x04
#define SPI_MEMORY_READ_STATUS            0x05
#define SPI_MEMORY_WRITE_LATCH_ENABLE     0x06
#define SPI_MEMORY_CHIP_ERASE             0xC7
#define SPI_MEMORY_SEC_EARSE              0x20	

/* Common data variables */

extern uint_8   send_buffer[];
extern uint_8   recv_buffer[];

/* Funtion prototypes */

extern void    set_CS (uint_32 cs_mask, uint_32 logic_level, pointer user_data);
extern void memory_sec_erase (MQX_FILE_PTR spifd,uint_32 secinaddr);
extern void    memory_chip_erase (MQX_FILE_PTR spifd);
extern void    memory_set_write_latch (MQX_FILE_PTR spifd, boolean enable);
extern void    memory_set_protection (MQX_FILE_PTR spifd, boolean protect, boolean lnk);
extern uint_8  memory_read_status (MQX_FILE_PTR spifd);
extern void    memory_write_byte (MQX_FILE_PTR spifd, uint_32 addr, uchar data);
extern uint_8  memory_read_byte (MQX_FILE_PTR spifd, uint_32 addr);
extern uint_32 memory_write_data (MQX_FILE_PTR spifd, uint_32 addr, uint_32 size, uchar_ptr data);
extern uint_32 memory_read_data (MQX_FILE_PTR spifd, uint_32 addr, uint_32 size, uchar_ptr data);
extern uint_32 memory_sec_modify(MQX_FILE_PTR spifd, uint_32 addr, uint_32 size, uchar_ptr data);

extern void Fun_ClearWatchDog(void);

#endif
/* EOF */
